<template>
  <div class="portal-list">
    <div class="protlet-title">
      <span>请选择布局</span>
      <close-outlined @click="evt_ls_close" />
    </div>
    <div class="portal-list-body">
      <layout :i-am-component="true" @i-am-component_click="iAmComponent_click"></layout>
      <layoutParams :is-show-prams="isShowPrams" :menu="checkitem" @layout-selected="layoutSelected"></layoutParams>
    </div>
  </div>
</template>

<script setup>
import { onMounted, defineEmits, ref, toRefs, defineProps, defineAsyncComponent } from 'vue'
import { CloseOutlined } from '@ant-design/icons-vue'
import layout from '@/views/manage/layout-manage/layout-manage'
import layoutParams from './layoutParams'

const props = defineProps({
  menuList: {
    type: Array,
    default: () => {
      return {}
    },
  },
})
const { menuList } = toRefs(props)

//==选择布局时,应用
const emit = defineEmits(['layoutSelected', 'evt_ls_close'])
const checkitem = ref({})
const iAmComponent_click = (item) => {
  checkitem.value = item
  isShowPrams.value = true
}

const layoutSelected = () => {
  menuList.value.portlets = []
  menuList.value.layout = [checkitem.value]
  emit('layoutSelected', '')
}
const evt_ls_close = () => {
  emit('evt_ls_close', '')
}

//==布局参数
const isShowPrams = ref(false)
</script>

<style scoped lang="less">
.portal-list {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: content-box;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: white;
  user-select: none;

  .protlet-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 15px;
    font-weight: bolder;
    font-size: 18px;

    span:nth-child(2) {
      cursor: pointer;
    }
  }

  .portal-list-body {
    display: flex;
    box-sizing: border-box;
    height: calc(100% - 40px);
    overflow: auto;
  }
}
</style>
